﻿using System;
namespace ORS.OrderRobot
{
	public class Consts
	{
		public class CacheKey
		{
            /// <summary>
            /// 系统配置
            /// </summary>
            public const string SystemConfig = "system";
            /// <summary>
            /// 用户信息
            /// </summary>
            public const string AccountPrefix = "user";
            /// <summary>
            /// 登机牌缓存列表
            /// </summary>
            public const string AllBoarding = "all-boarding";
            /// <summary>
            ///  代理池
            /// </summary>
            public const string ProxyPool = "ip";
            /// <summary>
            /// 订单
            /// </summary>
            public const string OrderPrefix = "order";
            /// <summary>
            /// 更新购物资料锁
            /// </summary>
            public const string ShopDepLock = "dep-lock";
            /// <summary>
            /// 获取登录用户的key
            /// </summary>
            /// <param name="email"></param>
            /// <returns></returns>
            public static string GenAccountLoginKey(string email)
            {
                return $"{AccountPrefix}|{email}";
            }
            /// <summary>
            /// 获取用户今日的订单key
            /// </summary>
            /// <param name="email"></param>
            /// <param name="productId"></param>
            /// <returns></returns>
            public static string GenAccountTodayOrderKey(string email,string productId)
            {
                var dateStr = DateTime.Now.ToString("yyyyMMdd");
                return $"{OrderPrefix}|{dateStr}|{email}";
            }
            /// <summary>
            /// 更新用户资料锁标识
            /// </summary>
            /// <param name="email"></param>
            /// <returns></returns>
            public static string GenShopDepLockKey(string email)
            {
                return $"{ShopDepLock}|{email}";
            }
            /// <summary>
            /// 自动下单任务锁
            /// </summary>
            public const string AutoShoppingTaskLock = "auto-shopping-lock";
            /// <summary>
            /// 自动扫描任务锁
            /// </summary>
            public const string ScanTaskLock = "scan-lock";
            /// <summary>
            /// 订购锁
            /// </summary>
            public const string PurchaseLock = "purchase-lock";
            /// <summary>
            /// 账号名和密码缓存
            /// </summary>
            public const string Accounts = "accounts";

            public const string LoginLock = "login-lock";

            public static string GenLoginLockKey(string email)
            {
                return $"{LoginLock}|{email}";
            }
        }
        /// <summary>
        /// 默认数据库连接字符传
        /// </summary>
        public const string ConnectName = "Default";
        public const string SignalRMethod = "ReceiveMessage";
        public const string WarnMsg = "warn";
        public const string ErrMsg = "err";
    }
}

